#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    //child
    printf("I am child process\n");
    sleep(5);
  }
  //parent
  int status = 0;
  pid_t ret = waitpid(id,&status,0);
  if(ret>0)
  {
    printf("wait success,ret = %d,子进程的退出码：%d,子进程的退出信号%d\n",ret,(status>>8)&0xFF,status&0x7F);
  }

  return 0;
}
